In [1]:
#%pylab inline
%pylab
import os
os.chdir('/Users/miguel_daal/Documents/Projects/Python_Res_Fit/KAM')
import KAM
reload(KAM)
from datetime import date
import collections
In [2]:
#cd /Users/miguel_daal/Documents/Projects/Python_Res_Fit/KAM
os.chdir('/Users/miguel_daal/Documents/Projects/Python_Res_Fit/KAM')
In [3]:
# import KAM
# reload(KAM)
# from datetime import date
# import os
In [4]:
widths = np.array([2,4,8,16,32,64,128,256])
Z3 = np.array([85.77,67.82,50.176,33.82,21.24,12.72,7.18,3.58])
Z3_dict = dict(zip(widths,Z3))
Z1 = np.array([52.10,52.10,52.10,52.10,52.10,52.10,52.10,52.10])
Z1_dict = dict(zip(widths,Z1))
Eeff = np.array([4.196,3.8148,3.2517,2.6174,2.09048,1.7018,1.4482,1.2773])
Eeff_dict = dict(zip(widths,Eeff))
In [5]:
Ver = 1
%run -i Load_Datasets.py
In [6]:
#data extraction conditions for power sweeps
#Power_Sweeps = [Run51aP,Run51bP,Run49aP ,Run48bP , Run48aP ,Run46aPl ,Run46aPh ,Run45bP ,Run45aP ,Run44bP ,Run44aP ,Run52b1st ,Run52b2nd]
condition = ['Q>0' ,'Q>0' ,'Pr<-65','Qc<700000', 'Pr<-68' ,'Qc>0' ,'(Q<210000)&(Qc>0)' ,'Pr<-45' ,'Pr<-60' ,'Qc<700000','Qc<200000','Q>0' ,'Q>0' ]
for sweep in xrange(len(Power_Sweeps)):
Power_Sweeps[sweep].metadata.condition = condition[sweep]
In [7]:
#sort power sweep list so that narrowest resonator is first and widest is last
Power_Sweeps.sort(key = lambda w: w.metadata.width)
In [71]:
def Plot_Data_Sets(X_expression, Y_expression, Xlabel = None, Ylabel = None, Title = None, Save = False,Point_Label = True,Marker_Map = True,Yscale = 'linear', Xscale = 'linear' ):
fig = plt.figure( figsize=(5,5), dpi=150)
ax = fig.add_subplot(111)
#norm = mpl.colors.Normalize(vmin=0, vmax=len(Power_Sweeps))
norm = mpl.colors.Normalize(vmin=2, vmax=8)
scalarMap = cm.ScalarMappable(norm=norm, cmap='gist_rainbow')
count = collections.Counter()
#markers = {1:',', 2:'x', 3:'+', 4:'1'}
markers = {1:'1', 2:'2', 3:'3', 4:'4'}
for sweep in xrange(len(Power_Sweeps)):
if Power_Sweeps[sweep].metadata.custom[0] == True: #the show flag
# If Power_Sweeps[sweep].metadata.condition references Pr, Q etc we will need to have these defined...
width = Power_Sweeps[sweep].metadata.width
Pr = Power_Sweeps[sweep].Sweep_Array['Preadout_dB']
Qc = Power_Sweeps[sweep].Sweep_Array['Qc']
Q = Power_Sweeps[sweep].Sweep_Array['Q']
Fr = Power_Sweeps[sweep].Sweep_Array['Fr']
Temp = Power_Sweeps[sweep].Sweep_Array['Temperature']
Qi = 1.0/((1.0/Q)-(1.0/Qc))
Pr_Volts_Peak = np.power(10,(Pr-10)/20) #Volts Peak
Pr_Watts = np.square(Pr_Volts_Peak)/(2*50)#watts
Pint = 10*np.log10(Pr_Watts*Q*Q/(np.pi*Qc)) #dBm
Imax = 2*Pr_Volts_Peak*Q/np.sqrt(np.pi*Z1_dict[width]*Z3_dict[width]*Qc) #Amps
Jmax = Imax/(width*1e-6*200e-9)
cond = eval(Power_Sweeps[sweep].metadata.condition)
X_array = eval(X_expression)
Y_array = eval(Y_expression)
xdict = dict(zip(X_array,arange(X_array.size)))
x = np.extract(cond,X_array)
y = np.extract(cond,Y_array)
if Marker_Map == True:
count[str(Power_Sweeps[sweep].metadata.width)] +=1
mark = markers[count[str(Power_Sweeps[sweep].metadata.width)]]
else:
mark ='.'
line = ax.plot(x,y, color = scalarMap.to_rgba(np.log2(Power_Sweeps[sweep].metadata.width)), label = str(Power_Sweeps[sweep].metadata.width)+ '$\mu m$; Run '+ Power_Sweeps[sweep].metadata.Run + Power_Sweeps[sweep].metadata.custom[1], linewidth=3,linestyle= Power_Sweeps[sweep].metadata.custom[2], marker = mark,markeredgecolor = 'k', markerfacecolor = 'k',markersize = 3 )
#line = ax.plot(x,y, color = scalarMap.to_rgba(sweep), label = str(Power_Sweeps[sweep].metadata.width)+ '$\mu m$; Run '+ Power_Sweeps[sweep].metadata.Run, linewidth=3,linestyle= '-', marker = '.', markerfacecolor = 'k' )
if Point_Label == True:
for i,j in zip(x,y):
if mod(xdict[i],5) == 0:
ax.annotate(str(xdict[i]),xy=(i,j), size = 4, rotation = 90,xytext=(i,j))
ax.legend(loc = 'best', fontsize=5,scatterpoints =1, numpoints = 1, labelspacing = .02)
#ax.set_ylim((-50000.0, 400000.0))
#ax.set_ylim((0.0, 600000.0)) #for Qc
#ax.set_xlim((-118.0, -20.0))
ax.ticklabel_format(axis='y', style='sci',useOffset=False)
ax.set_ylabel(Ylabel, color='k')
ax.set_xlabel(Xlabel, color='k')
ax.xaxis.labelpad = 10 #move the xlabel down a bit, also possible with ax.xaxis.set_label_coords(0.5, -0.1)
ax.set_xscale(Xscale)
ax.set_yscale(Yscale)
ax.set_title(Title)
plt.subplots_adjust(left=.2, bottom=0.13, right=None, top=None)
ax.tick_params(axis='y', labelsize=9)
ax.tick_params(axis='x', labelsize=9)
ax.grid()
plt.show()
if Save == True:
#loc = os.getcwd()
#os.chdir(loc+os.sep+'Plots')
loc = '/Users/miguel_daal/Documents/Projects/Python_Res_Fit/KAM'
os.chdir('/Users/miguel_daal/Documents/Projects/Python_Res_Fit/KAM/Plots/')
fig.savefig(Title.replace('\n','_').replace(' ','_')+'_'+date.today().strftime("%Y%m%d"),dpi=300, transparency = True)
os.chdir(loc)
In [72]:
if 1:
Save = True
Xlabel = 'Probe Power [dBm]'
Ylabel = 'Internal Quality Factor, $Q_i$'
Title = 'Effect of Probe Power on\nInternal Quality Factor'
Plot_Data_Sets("Pr", "Qi", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False)
if 1:
Save = False
Xlabel = 'Probe Power [dBm]'
Ylabel = 'Coupling Quality Factor, $Q_c$'
Title = 'Effect of Probe Power on\nCoupling Quality Factor'
Plot_Data_Sets("Pr", "Qc", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False)
if 0:
Save = False
Xlabel = 'Probe Power [dBm]'
Ylabel = 'Loop Diameter, $Q/Q_c$'
Title = 'Effect of Probe Power on\nLoop Diameter'
Plot_Data_Sets("Pr", "Q/Qc", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False)
if 0:
Save = False
Xlabel = 'Probe Power [dBm]'
Ylabel = r'Fractional Resonant Frequency Shift, $\delta f_r/f_r$'
Title = 'Effect of Probe Power on\nResonance Frequency Shift'
Plot_Data_Sets("Pr", "(Fr-Fr[0])/Fr[0]", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False)
In [9]:
In [9]:
In [10]:
Save = False
Xlabel = r'Resonator Internal Power, $\frac{Q^2\cdot P_{probe}}{Q_c \pi}$ [dBm]'
Ylabel = r'Internal Quality Factor $Q_i$'
Title = 'Internal Quality Factor versus\nInternal Power'
Plot_Data_Sets("Pint", "Qi", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False)
In [11]:
if 0:
Save = False
Xlabel = r'Resonator Max Current, $I_{max}$ [Amps]'
Ylabel = r'Internal Quality Factor $Q_i$'
Title = 'Internal Quality Factor versus\nMax Current'
Plot_Data_Sets("Imax", "Qi", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current, $I_{max}$ [Amps]'
Ylabel = r'Coupling Quality Factor $Q_c$'
Title = 'Coupling Quality Factor versus\nMax Current'
Plot_Data_Sets("Imax", "Qc", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current, $I_{max}$ [Amps]'
Ylabel = r'Loop Diameter, $Q/Q_c$'
Title = 'Loop Diameter versus\nMax Current'
Plot_Data_Sets("Imax", "Q/Qc", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current, $I_{max}$ [Amps]'
Ylabel = r'Quality Factor $Q$'
Title = 'Quality Factor versus\nMax Current'
Plot_Data_Sets("Imax", "Q", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current, $I_{max}$ [Amps]'
Ylabel = r'Fractional Resonant Frequency Shift, $\delta f_r/f_r$'
Title = 'Resonance Frequency Shift versus\nMax Current'
Plot_Data_Sets("Imax", "(Fr-Fr[0])/Fr[0]", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False,Xscale = 'log')
In [12]:
if 0:
Save = False
Xlabel = r'Resonator Max Current Density, $J_{max}$ [Amps/m^2]'
Ylabel = r'Internal Quality Factor $Q_i$'
Title = 'Internal Quality Factor versus\nMax Current Density'
Plot_Data_Sets("Jmax", "Qi", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current Density, $J_{max}$ [Amps/m^2]'
Ylabel = r'Coupling Quality Factor $Q_c$'
Title = 'Coupling Quality Factor versus\nMax Current Density'
Plot_Data_Sets("Jmax", "Qc", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current Density, $J_{max}$ [Amps/m^2]'
Ylabel = r'Loop Diameter, $Q/Q_c$'
Title = 'Loop Diameter versus\nMax Current Density'
Plot_Data_Sets("Jmax", "Q/Qc", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current Density, $J_{max}$ [Amps/m^2]'
Ylabel = r'Quality Factor $Q$'
Title = 'Quality Factor versus\nMax Current Density'
Plot_Data_Sets("Jmax", "Q", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False, Xscale = 'log')
if 0:
Save = False
Xlabel = r'Resonator Max Current Density, $J_{max}$ [Amps/m^2]'
Ylabel = r'Fractional Resonant Frequency Shift, $\delta f_r/f_r$'
Title = 'Resonance Frequency Shift versus\nMax Current Density'
Plot_Data_Sets("Jmax", "(Fr-Fr[0])/Fr[0]", Xlabel = Xlabel, Ylabel = Ylabel, Title = Title, Save = Save, Point_Label = False,Xscale = 'log')
In [12]:
In [12]:
In [12]:
In [15]:
#fig = plt.figure( figsize=(5.5, 4.5), dpi=100)
fig = plt.figure( figsize=(5, 5), dpi=150)
ax = fig.add_subplot(111)
sweep = Run45aP
index = 0; line1 = ax.plot(sweep.Sweep_Array['Frequencies'][index]/1e6,20*np.log10(np.abs(sweep.Sweep_Array['S21'][index])), label = '-100 dBm Probe Power', linewidth=3,linestyle= '-')
index = 8; line2 = ax.plot(sweep.Sweep_Array['Frequencies'][index]/1e6,20*np.log10(np.abs(sweep.Sweep_Array['S21'][index])), label = '-72 dBm Probe Power', linewidth=3,linestyle= '-')
index = 11; line3 = ax.plot(sweep.Sweep_Array['Frequencies'][index]/1e6,20*np.log10(np.abs(sweep.Sweep_Array['S21'][index])), label = '-66 dBm Probe Power', linewidth=3,linestyle= '-')
#index = 18; line4 = ax.plot(sweep.Sweep_Array['Frequencies'][index]/1e6,20*np.log10(np.abs(sweep.Sweep_Array['S21'][index])), label = '-52 dBm Probe Power', linewidth=3,linestyle= '-')
#S21_log_dB = lambda Q,Qc,Fr:
ax.set_xlabel('Frequency [MHz]',color = 'k')
#ax.xaxis.get_major_formatter().set_powerlimits((0, 1))
ax.ticklabel_format(axis='x', style='plain', scilimits=(0,0),useOffset=False)
ax.xaxis.set_major_locator(plt.LinearLocator(5))
ax.set_ylabel('$|S_{21}|$ [dB]', color='k')
ax.set_title('Trsansmission Around Resonance at Different Powers: \n\n 64 $\mu m$ wide Al microstrip on Nb ground plane, Run 45a', fontsize=9)
ax.legend(loc = 'best', fontsize=9)
#ax.legend(loc = 'lower center', fontsize=9, bbox_to_anchor=(0.5, 0), ncol=2)
ax.grid()
plt.subplots_adjust(left=.15, bottom=.15, right=None, top=.85)
plt.show()
def Print_Quantities(index):
sweep = Run45aP
Q = sweep.Sweep_Array['Q'][index]
Qc = sweep.Sweep_Array['Qc'][index]
Qi = 1.0/((1.0/Q)-(1.0/Qc))
Pr = sweep.Sweep_Array['Preadout_dB'][index]
print('Q = {0}; Qc = {1}; Qi = {2}; Pr = {3}'.format(Q, Qc,Qi,Pr))
Print_Quantities(0)
Print_Quantities(8)
Print_Quantities(11)
#fig.savefig('Transmission_at_Different_Powers', dpi = 300, transparency = True)
In [14]:
sweep = Run45aP
print(sweep.Sweep_Array['Pinput_dB'])
def plot_routine(index):
sweep.pick_loop(index)
sweep.decompress_gain(Compression_Calibration_Index = -1, Show_Plot = False, Verbose = False)
sweep.remove_cable_delay(Show_Plot = False, Verbose = False)
sweep.circle_fit(Show_Plot = True)
sweep.phase_fit(Fit_Method = 'Multiple',Verbose = True, Show_Plot = True)
print(sweep.loop.Phase_Fit_Method)
plot_routine(11)
In [ ]:
Run45aP.metadata.LNA
In [ ]:
In [ ]: